<?php
/**
 * created by zzy
 * date: 2018/1/26 14:07
 */


namespace App\Http\Admin\Ajax\Controllers;

use App\Eloquent\Area;
use App\Eloquent\City;
use App\Eloquent\Province;
use Framework\BaseClass\Http\Admin\Controller;

class IndexController extends Controller
{
    public function address()
    {
        $type               = request('type',1);
        $value              = request('value',0);
        //$type 1省 2市 3县
        switch ($type)
        {
            case 1:
                $data       = Province::get()->toArray();
                break;
            case 2:
                $where      = ['fatherID'=>$value];
                $data       = City::where($where)->get()->toArray();
                break;
            case 3:
                $where      = ['fatherID'=>$value];
                $data       = Area::where($where)->get()->toArray();
                break;
            default:
                $data       =[];
        }
        $result             = json_encode($data);
        return $result;
    }
}